package com.example.online_exam_system.service.impl;

import com.example.online_exam_system.dao.TeacherDao;
import com.example.online_exam_system.dto.TeacherregDto;
import com.example.online_exam_system.entity.Teacher;
import com.example.online_exam_system.service.TeacherService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


/**
 * (Teacher)表服务实现类
 *
 * @author lianglong@asiainfo.com
 * @since 2021-11-25 13:58:39
 */
@Service("teacherService")
public class TeacherServiceImpl implements TeacherService {
    @Resource
    private TeacherDao teacherDao;

    /**
     * 通过ID查询单条数据
     *
     * @param teacherid 主键
     * @return 实例对象
     */
    @Override
    public Teacher queryById(Object teacherid) {
        return this.teacherDao.queryById(teacherid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<Teacher> queryAllByLimit(int offset, int limit) {
        return this.teacherDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param teacher 实例对象
     * @return 实例对象
     */
    @Override
    public Teacher insert(Teacher teacher) {
        this.teacherDao.insert(teacher);
        return teacher;
    }

    @Override
    public int insert(TeacherregDto teacherregDto) {
        return this.teacherDao.insert(teacherregDto);
    }

    /**
     * 修改数据
     *
     * @param teacher 实例对象
     * @return 实例对象
     */
    @Override
    public Teacher update(Teacher teacher) {
        this.teacherDao.update(teacher);
        return this.queryById(teacher.getTeacherid());
    }

    /**
     * 通过主键删除数据
     *
     * @param teacherid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Object teacherid) {
        return this.teacherDao.deleteById(teacherid) > 0;
    }


    @Override
    public List<Map<String, Object>> queryByuserName(Map<String, Object> inParam) {
        return this.teacherDao.queryByuserName(inParam);
    }

    @Override
    public Map<String, Object> getTeacherInfo(String realname) {
        return teacherDao.getTeacherInfo(realname);
    }

    @Override
    public String getTeacherId(String realname) {
        return teacherDao.getTeacherId(realname);
    }

    @Override
    public String getPassword(Map<String, Object> inParam) {
        String password = teacherDao.getPassword(inParam);
        return password;
    }

    @Override
    public int updateTeacherInfo(Map<String, Object> inParam) {
        return teacherDao.updateTeacherInfo(inParam);
    }

    @Override
    public Map<String, Object> queryByUserId(String teacherId) {
        return teacherDao.queryByUserId(teacherId);
    }

    @Override
    public List<Map<String, Object>> getAllInfo() {
        return teacherDao.getAllInfo();
    }

}
